package damin_kafka;

import java.util.Properties;

public class JavaKafkaConfigurer {
    private static Properties properties;

    public static void configureSasl() {
        //如果用-D 或者其它方式设置过，这里不再设置
        if (null == System.getProperty("java.security.auth.login.config")) {
            //请注意将 XXX 修改为自己的路径
            //这个路径必须是一个文件系统可读的路径，不能被打包到 jar 中
            System.setProperty("java.security.auth.login.config", getKafkaProperties().getProperty("java.security.auth.login.config"));
        }
    }

    public synchronized static Properties getKafkaProperties() {
        if (null != properties) {
            return properties;
        }
        //获取配置文件 kafka.properties 的内容
        Properties kafkaProperties = new Properties();
        try {
            kafkaProperties.load(KafkaProducerDemo.class.getClassLoader().getResourceAsStream("kafka.properties"));
        } catch (Exception e) {
            //没加载到文件，程序要考虑退出
            e.printStackTrace();
        }
        properties = kafkaProperties;

        String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ADI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">  <Objects>    <Object ElementType=\"Program\" ContentID=\"prog99cp000001155954234482067578\" Action=\"REGIST\">      <Property Name=\"Name\">云公司-下发正式调试-001</Property>      <Property Name=\"FileURL\"></Property>      <Property Name=\"Description\"></Property>      <Property Name=\"StarLevel\">0</Property>      <Property Name=\"Length\">0</Property>      <Property Name=\"SeriesFlag\">0</Property>      <Property Name=\"Status\">1</Property>      <Property Name=\"OriginalCountry\"></Property>      <Property Name=\"LicensingWindowStart\">null</Property>      <Property Name=\"LicensingWindowEnd\">null</Property>      <Property Name=\"DisplayAsNew\">0</Property>      <Property Name=\"DisplayAsLastChance\">0</Property>      <Property Name=\"Macrovision\">0</Property>      <Property Name=\"PriceTaxIn\">0.0</Property>      <Property Name=\"SourceType\">0</Property>      <Property Name=\"OrderNumber\"></Property>    </Object>    <Object ElementType=\"Movie\" PhysicalContentID=\"movi99cp000001155979146752018279\" Action=\"REGIST\" Type=\"1\">      <Property Name=\"HotDegree\">0</Property>      <Property Name=\"FileURL\">ftp://iptv:Iptv2019CDN@221.228.56.5/yueme/video/t1.ts</Property>      <Property Name=\"Duration\">0</Property>      <Property Name=\"FileSize\">0</Property>      <Property Name=\"SourceBitRate\">0.0</Property>      <Property Name=\"SourceDRMType\">0</Property>      <Property Name=\"DestDRMType\">0</Property>      <Property Name=\"AudioType\">0</Property>      <Property Name=\"ScreenFormat\">0</Property>      <Property Name=\"ClosedCaptioning\">0</Property>      <Property Name=\"BitRateType\">0</Property>      <Property Name=\"VideoType\">0</Property>      <Property Name=\"AudioEncodingType\">0</Property>      <Property Name=\"Resolution\">0</Property>      <Property Name=\"VideoProfile\">0</Property>      <Property Name=\"SystemLayer\">0</Property>      <Property Name=\"Domain\">0</Property>    </Object>  </Objects>  <Mappings>    <Mapping ParentType=\"Program\" ParentID=\"prog99cp000001155954234482067578\" ElementType=\"Movie\" \tElementID=\"movi99cp000001155979146752018279\" ObjectID=\"mapp99cp000001155980770967375490\" Action=\"REGIST\"></Mapping>  </Mappings></ADI>";
        return kafkaProperties;
    }
}
